package com.ost.kautilya.modeling;


public class ModelConfigurationParameter implements Comparable<ModelConfigurationParameter> {
	private String name;
	protected String desc;
	protected String dval;
	protected boolean on = true;
	protected boolean isf;
	private int index;

	public ModelConfigurationParameter(int index, String name2, String description) {
		name = name2;
		desc = description;
		this.index = index;
	}
	
	@Override
	public int compareTo(ModelConfigurationParameter p) {
		return index - p.index;
	}
	
	public ModelConfigurationParameter(int index, String name2, String description, String dval, boolean isflag, boolean ison) {
		this(index, name2, description);
		this.dval = dval;
		isf = isflag;
		on = ison;
	}

	public String getName() {
		return name;
	}
	
	public String getApplicableName() {
		return "".equals(name) ? String.valueOf(index) : name;
	}

	public String getDescription() {
		return desc;
	}
	
	public String getDefaultValue() {
		return dval;
	}
	
	public boolean isAvailable() {
		return on;
	}
	
	public boolean isFlag() {
		return isf;
	}
	
	@Override
	public String toString() {
		return getApplicableName();
	}
	
	@Override
	public boolean equals(Object obj) {
		return (obj instanceof ModelConfigurationParameter && (((ModelConfigurationParameter) obj).getApplicableName().equalsIgnoreCase(getApplicableName()))) || (obj instanceof String && obj.equals(getApplicableName()));
	}
	
	@Override
	public int hashCode() {
		return getApplicableName().hashCode();
	}
}
